<%@ page language="java" contentType="text/html; charset=UTF-8" 
	pageEncoding="UTF-8" %>
<html>
<head>
<script language="javascript" src="./Sheet/ibsheet.js"></script>
<script language="javascript" src="./Sheet/ibsheetinfo.js"></script>

<script language="javascript">

function LoadPage() {
	var cfg = {SearchMode:1,Page:10};
	mySheet.SetConfig(cfg);

	var headersT = [{Text:"상태|구분|부서명|부서코드|조직레벨|조직 순차|조직 시작일|조직 종료일|상위 조직 코드|조직장여부|비고",Align:"Center"}	];
	var info = {Sort:0,ColMove:1,ColResize:1};
	mySheet.InitHeaders(headersT,info);
	
	var colsT = [
				{Type:"Status",Width:60,SaveName:"sStatus",Align:"Center"},
				{Type:"DelCheck",Width:60,SaveName:"sDelete",Align:"Center"},
				{Type:"Text",Width:250,TreeCol:4,SaveName:"DEPTNAME"},
				{Type:"Text",Width:65,SaveName:"DEPTNO",Align:"Center"},
			    {Type:"Text",Width:60,SaveName:"DEPTLEVEL",Edit:0,Align:"Center"},
				{Type:"Text",Width:60,SaveName:"DEPTSTEP",Hidden:1,Align:"Center"},
			    {Type:"Date",Width:100,SaveName:"DEPTSTDATE",Format:"Ymd",Align:"Center",EditLen:8},
	        	{Type:"Date",Width:100,SaveName:"DEPTENDATE",Format:"Ymd",Align:"Center",EditLen:8},
	            {Type:"Text",Width:100,SaveName:"DEPTPRCODE",Align:"Center"},
	            {Type:"Text",Width:100,SaveName:"DEPTCHIEF",Align:"Center"},
	            {Type:"Text",Width:200,SaveName:"ETC",Align:"Center"},
			];


	mySheet.InitColumns(colsT);
	//mySheet.mySheet_Onclick();
    //mySheet.FitColWidth("5|5|10|10|10|10|10|10|10|10|10");
    	
		
	//Detail Sheet 
		
	var cfgD = {SearchMode:2,Page:10};
	mySheetD.SetConfig(cfgD);

	var headerD = [{Text:"상태|사번|이름|부서코드|직위|직책|직급|발령시작일|발령종료일",Align:"Center"}];
	var infoD = {Sort:0,ColMove:1,ColResize:1};
	mySheetD.InitHeaders(headerD,infoD);

	var colsD = [
	             {Type:"Status",Width:60,SaveName:"sStatus",Align:"Center"},
                 {Type:"Text",Width:100,SaveName:"ID",Edit:0,Align:"Center"},
                 {Type:"Text",Width:100,SaveName:"NAMEKOR",Edit:0,Align:"Center"},
                 {Type:"Text",Width:65,Align:"Center",SaveName:"DEPTNO",Edit:0},
                 {Type:"Text",Width:60,SaveName:"POSITIONCODE",Edit:0,Align:"Center"},
	             {Type:"Text",Width:150,SaveName:"DUTYCODE",Edit:0,Align:"Center"},
				 {Type:"Text",Width:150,SaveName:"CLASSCODE",Edit:0,Align:"Center"},
 	             {Type:"Date",Width:120,SaveName:"APPSTARTDATE",Edit:0,Format:"Ymd",Align:"Center",EditLen:8},
	             {Type:"Date",Width:120,SaveName:"APPENDDATE",Edit:0,Format:"Ymd",Align:"Center",EditLen:8},
	             
                ];


	mySheetD.InitColumns(colsD);
	mySheetD.SetCountPosition(3);
}

	function doAction(str){
		switch(str){
		
		  	case "Search":      //조회
		  		  //mySheet.DoSearch("deptreedata.xml");
		  		  mySheet.DoSearch("deptTreeXml.jsp");
		  		  break;
		  	case "Remove":
		  		  mySheet.RemoveAll(true);
		  		   break;	
			case "Insert" :
				var row = mySheet.DataInsert();
				mySheet.SetCellText(row,8,mySheet.GetCellText(row-1,3));
				var tot = mySheet.GetCellText(row-1,4);
				mySheet.SetCellText(row,4,eval(tot)+1);
				mySheet_Onclick(row);
				break;
			case "Save" :
				mySheet.DoSave("save.jsp");
				break;	
			/*
			case "search":
				var param = "dept_name="+document.frm.dept_name.value;
			*/
				//var param = "sa_name="+document.frm.sa_name.value+"&sal="+document.frm.sal.value+"&hdate="+document.frm.hdate.value;				
				//mySheet.DoSearch("dataList.jsp",param);
				//var xml  = mySheet.GetSearchData("dataList.jsp",param);
				//break;
			/*case "save":
				//var param = "sa_name="+document.frm.sa_name.value+"&sal="+document.frm.sal.value+"&hdate="+document.frm.hdate.value;
				mySheet.DoSave("save.jsp");
				break;
			*/
		}
	}
		
	function doActionD(str){
		switch(str){
			case "Search":
				var param = "ID="+document.frmDetail.id.value + "&NAME="+document.frmDetail.name.value;
				mySheetD.DoSearch("empDetailDataList.jsp",param);
				
				//mySheetD.DoSearch("empDetailDataList.jsp",param);
				break;
		}
	}
	
	/*
	function mySheet_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		var saveStr = mySheet.RowSaveStr(Row);
		alert(saveStr);
	    location.href = "./dept.jsp?key=" + saveStr;
	}
	*/
	
	function mySheet_OnClick(Row) {
		var saveStr = "DEPTNO="+mySheet.GetCellText(Row,3);
		mySheetD.DoSearch("empDetailDataList.jsp",saveStr);
		
	    //location.href = "./dept.jsp?key=" + saveStr;
	}
	
</script>

</head>

<body onload="LoadPage()">

	<form name="frm">
		<table>
			<tr>
				<td>
				    <input type="button" value="추가" onclick="doAction('Insert')"/> 
				    <input type="button" value="조회" onclick="doAction('Search')"/>
					<input type="button" value="저장" onclick="doAction('Save')"/>
					<input type="button" value="초기화" onclick="doAction('Remove')"/>
				</td>
			</tr>
		</table>
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<script language="javascript">
						createIBSheet("mySheet", "926px", "300px");
					</script>
				</td>
			</tr>
		</table>
	</form>
	
	<form name="frmDetail">
		<table cellpadding="0" cellspacing="0">
			<tr>
			<td bgcolor="#EEEEEE">
				<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td bgcolor="#eeeeff" width="100px" align="center">사번</td>
					<td bgcolor="#eeeeff"><input type="text" name="id"></td>
					
					<td bgcolor="#eeeeff" width="100px" align="center">이름</td>
					<td bgcolor="#eeeeff"><input type="text" name="name"></td>
				</tr>
				</table>
			</td>
			<td width="40px"></td>
			<td><input type="button" value="  사원 조회  " onclick="doActionD('Search')"></td>
		</tr>
		</table>
	
		<table cellpadding="0" cellspacing="0">
		<tr>
			<td width="100%">
				<script language="javascript">
					createIBSheet("mySheetD", "926px", "300px");
				</script>
			</td>
		</tr>
		</table>
	</form>
	
</body>
</html>